﻿/*
* ============================================================================
* GNU Lesser General Public License
* ============================================================================
*
* BYDAN - Free Java BYDAN library.
* Copyright (C) 2008 
* 
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* 
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
* Lesser General Public License for more details.
* 
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307, USA.
* 
* BYDAN Corporation
*/
package ByDan.AulaVirtual.Business.Entities;

import java.util.ArrayList;
import ByDan.Framework.AulaVirtual.Business.Entities.GeneralEntity;
import ByDan.Framework.AulaVirtual.Business.Entities.Mensajes;
import ByDan.Framework.AulaVirtual.Utils.ParameterDbType;
import ByDan.Framework.AulaVirtual.Utils.ParameterType;
import ByDan.Framework.AulaVirtual.Utils.ParametersMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterMaintenance;
import ByDan.Framework.AulaVirtual.Utils.ParameterValue;
import ByDan.Framework.AulaVirtual.Utils.ParametersType;
import java.sql.*;

public class Tutor extends GeneralEntity
{
	static  String strTableName="Tutor";
		
	public static String getStrTableName() 
	{
		return strTableName;
	}

	public static void setStrTableName(String strTableName) 
	{
		Tutor.strTableName = strTableName;
	}
	
	public static String getColumnNameId()
	{
		return "id";
	}
	
	public Tutor tutorOriginal;
	
	public Tutor getTutorOriginal()
	{
		return tutorOriginal;
	}
	
	public  void  setTutorOriginal(Tutor tutor)
	{
		try
		{
			tutorOriginal=tutor;
		}
		catch(Exception ex)
		{
			;
		}
	}
	
	
	
	
	TipoCertificacion relationship_tipocertificacion;
	 
	
	public TipoCertificacion getRelationship_TipoCertificacion()
	{
		return relationship_tipocertificacion;
	}

	
	
	public  void  setRelationship_TipoCertificacion(TipoCertificacion tipocertificacion)
	{
		try
		{
			relationship_tipocertificacion=tipocertificacion;
		}
		catch(Exception ex)
		{
			;
		}
	}


	
	
	ArrayList<UnidadCurricularTutor> relationship_unidadcurriculartutors;
	ArrayList<UnidadCurricular> relationship_unidadcurriculars;
	
	
	public ArrayList<UnidadCurricularTutor> getRelationship_unidadcurriculartutors()
	{
		return relationship_unidadcurriculartutors;
	}

	public ArrayList<UnidadCurricular> getRelationship_unidadcurriculars()
	{
		return relationship_unidadcurriculars;
	}

	
	
	public  void  setRelationship_UnidadCurricularTutor(ArrayList<UnidadCurricularTutor> unidadcurriculartutors)
	{
		try
		{
			this.relationship_unidadcurriculartutors=unidadcurriculartutors;
		}
		catch(Exception ex)
		{
			;
		}
	}

	public  void  setRelationship_UnidadCurricular(ArrayList<UnidadCurricular> unidadcurriculars)
	{
		try
		{
			this.relationship_unidadcurriculars=unidadcurriculars;
		}
		catch(Exception ex)
		{
			;
		}
	}

	
	private static Boolean blnDeleteCascade=false;
	private static String QueryInsert="insert into aulavirtualme_dbo.Tutor set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,IDTIPOCERTIFICACION=?,CEDULA=?,NOMBRE=?,ESTADO=?,NUMEROTELEFONO=?,OBSERVACIONES=?";
	private static String QueryUpdate="update aulavirtualme_dbo.Tutor set ISACTIVE=?,ISEXPIRED=?,VERSIONROW=CURRENT_TIMESTAMP,IDTIPOCERTIFICACION=?,CEDULA=?,NOMBRE=?,ESTADO=?,NUMEROTELEFONO=?,OBSERVACIONES=? where id=? AND versionRow=?";
	private static String QueryDelete="delete from aulavirtualme_dbo.Tutor where id=?";
	public static String QuerySelect="select aulavirtualme_dbo.Tutor.id,aulavirtualme_dbo.Tutor.isActive,aulavirtualme_dbo.Tutor.isExpired,aulavirtualme_dbo.Tutor.versionRow,aulavirtualme_dbo.Tutor.IDTIPOCERTIFICACION,aulavirtualme_dbo.Tutor.CEDULA,aulavirtualme_dbo.Tutor.NOMBRE,aulavirtualme_dbo.Tutor.ESTADO,aulavirtualme_dbo.Tutor.NUMEROTELEFONO,aulavirtualme_dbo.Tutor.OBSERVACIONES from aulavirtualme_dbo.Tutor";
	 
	Long field_bigIdTipoCertificacion;
	String field_strCedula;
	String field_strNombre;
	Boolean field_bitEstado;
	String field_strNumerotelefono;
	String field_strObservaciones;
				
	public Tutor ()
    {
		super();		
 		field_bigIdTipoCertificacion=-1L;
 		field_strCedula="";
 		field_strNombre="";
 		field_bitEstado=false;
 		field_strNumerotelefono=null;
 		field_strObservaciones=null;
		
		
		relationship_tipocertificacion=new TipoCertificacion();
		
		
		relationship_unidadcurriculartutors=new ArrayList<UnidadCurricularTutor>();
		relationship_unidadcurriculars=new ArrayList<UnidadCurricular>();
		
		super.setQueryInsert(QueryInsert);
		super.setQueryUpdate(QueryUpdate);
		super.setQueryDelete(QueryDelete);
		super.setQuerySelect(QuerySelect);
		
    } 
	
	public static Boolean getBlnDeleteCascade() 
	{
		return blnDeleteCascade;
	}

	public static void setBlnDeleteCascade(Boolean blnDeleteCascade) 
	{
		Tutor.blnDeleteCascade = blnDeleteCascade;
	}
	
	public static String getTableName()
    {
         return "aulavirtualme_dbo.Tutor";
    }
	
    
	public static String getColumnNameidTipoCertificacion()
	{
		return "idTipoCertificacion";
	}
    
	public static String getColumnNameCedula()
	{
		return "Cedula";
	}
    
	public static String getColumnNameNombre()
	{
		return "Nombre";
	}
    
	public static String getColumnNameEstado()
	{
		return "Estado";
	}
    
	public static String getColumnNameNumeroTelefono()
	{
		return "NumeroTelefono";
	}
    
	public static String getColumnNameObservaciones()
	{
		return "Observaciones";
	}
     
    
	public Long getField_bigIdTipoCertificacion()
	{
		return field_bigIdTipoCertificacion;
	}
    
	public String getField_strCedula()
	{
		return field_strCedula;
	}
    
	public String getField_strNombre()
	{
		return field_strNombre;
	}
    
	public Boolean getField_bitEstado()
	{
		return field_bitEstado;
	}
    
	public String getField_strNumerotelefono()
	{
		return field_strNumerotelefono;
	}
    
	public String getField_strObservaciones()
	{
		return field_strObservaciones;
	}
	
    
	public void setField_bigIdTipoCertificacion(Long newField_bigIdTipoCertificacion)throws Exception
	{
		try
		{
			if(this.field_bigIdTipoCertificacion!=newField_bigIdTipoCertificacion)
			{
				if(newField_bigIdTipoCertificacion==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Tutor.getColumnNameidTipoCertificacion());
				}

				this.field_bigIdTipoCertificacion=newField_bigIdTipoCertificacion;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strCedula(String newField_strCedula)throws Exception
	{
		try
		{
			if(this.field_strCedula!=newField_strCedula)
			{
				if(newField_strCedula==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Tutor.getColumnNameCedula());
				}

				this.field_strCedula=newField_strCedula;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strNombre(String newField_strNombre)throws Exception
	{
		try
		{
			if(this.field_strNombre!=newField_strNombre)
			{
				if(newField_strNombre==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Tutor.getColumnNameNombre());
				}

				this.field_strNombre=newField_strNombre;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_bitEstado(Boolean newField_bitEstado)throws Exception
	{
		try
		{
			if(this.field_bitEstado!=newField_bitEstado)
			{
				if(newField_bitEstado==null)
				{
					throw new Exception(this.getTableName()+":"+ Mensajes.getMensajeExcepcionValorNulo()+" en columna "+Tutor.getColumnNameEstado());
				}

				this.field_bitEstado=newField_bitEstado;
				this.setIsChanged(true);
			}
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
    
	public void setField_strNumerotelefono(String newField_strNumerotelefono)
	{
		if(this.field_strNumerotelefono!=newField_strNumerotelefono)
		{
			this.field_strNumerotelefono=newField_strNumerotelefono;
			this.setIsChanged(true);
		}
	}
    
	public void setField_strObservaciones(String newField_strObservaciones)
	{
		if(this.field_strObservaciones!=newField_strObservaciones)
		{
			this.field_strObservaciones=newField_strObservaciones;
			this.setIsChanged(true);
		}
	}
		
	public  void BuildParametersMaintenance(ParameterDbType newDbType,ParametersType parametersType) throws Exception
	{
		try
		{
			ParametersMaintenance parametersMaintenance=super.getParametersMaintenance();		
			ArrayList<ParameterMaintenance> parametersTemp=new ArrayList<ParameterMaintenance>();
			ParameterMaintenance parameterMaintenance;
			ParameterValue<Long> parameterMaintenanceValueId;
			
				if(!parametersType.equals(ParametersType.DELETE))
				{		
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsactive=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsactive.setValue(this.getIsActive());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsactive);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(2);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueIsexpired=new ParameterValue<Boolean>();
					parameterMaintenanceValueIsexpired.setValue(this.getIsExpired());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIsexpired);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(3);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					ParameterValue<Long> parameterMaintenanceValueIdTipoCertificacion=new ParameterValue<Long>();
					parameterMaintenanceValueIdTipoCertificacion.setValue(this.getField_bigIdTipoCertificacion());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueIdTipoCertificacion);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(4);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueCedula=new ParameterValue<String>();
					parameterMaintenanceValueCedula.setValue(this.getField_strCedula());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueCedula);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(5);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueNombre=new ParameterValue<String>();
					parameterMaintenanceValueNombre.setValue(this.getField_strNombre());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueNombre);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(6);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.BOOLEAN);
					ParameterValue<Boolean> parameterMaintenanceValueEstado=new ParameterValue<Boolean>();
					parameterMaintenanceValueEstado.setValue(this.getField_bitEstado());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueEstado);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(7);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueNumerotelefono=new ParameterValue<String>();
					parameterMaintenanceValueNumerotelefono.setValue(this.getField_strNumerotelefono());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueNumerotelefono);
					parametersTemp.add(parameterMaintenance);
					
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(8);		
					parameterMaintenance.setParameterMaintenanceType(ParameterType.STRING);
					ParameterValue<String> parameterMaintenanceValueObservaciones=new ParameterValue<String>();
					parameterMaintenanceValueObservaciones.setValue(this.getField_strObservaciones());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueObservaciones);
					parametersTemp.add(parameterMaintenance);
					
						if(parametersType.equals(ParametersType.UPDATE))
						{					
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(9);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
							parameterMaintenanceValueId=new ParameterValue<Long>();
							parameterMaintenanceValueId.setValue(this.getId());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
							parametersTemp.add(parameterMaintenance);
							
							parameterMaintenance=new ParameterMaintenance();
							parameterMaintenance.setOrder(10);
							parameterMaintenance.setParameterMaintenanceType(ParameterType.TIMESTAMP);
							ParameterValue<Timestamp> parameterMaintenanceValueVersionRow=new ParameterValue<Timestamp>();
							parameterMaintenanceValueVersionRow.setValue(this.getVersionRow());
							parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueVersionRow);		
							parametersTemp.add(parameterMaintenance);					
						}
				}
				else
				{
					parameterMaintenance=new ParameterMaintenance();
					parameterMaintenance.setOrder(1);
					parameterMaintenance.setParameterMaintenanceType(ParameterType.LONG);
					parameterMaintenanceValueId=new ParameterValue<Long>();
					parameterMaintenanceValueId.setValue(this.getId());
					parameterMaintenance.setParameterMaintenanceValue(parameterMaintenanceValueId);		
					parametersTemp.add(parameterMaintenance);
				}
			
			parametersMaintenance= new ParametersMaintenance();
			parametersMaintenance.setDbType(newDbType);
			parametersMaintenance.setParametersMaintenance(parametersTemp);
			super.setParametersMaintenance(parametersMaintenance);		
		}
		catch(Exception ex)
		{
			throw ex;
		}
	}
}
